<?php
error_reporting(E_WARNING);
include_once '../includes/metodos.php';
include_once 'action.php';
connectSql();
checkUser();

if(!empty($_POST['cmd']) && $_POST['cmd']=='edit'){
	edit($_POST['id']);
}

if(!empty($_POST['cmd']) && $_POST['cmd']=='del'){
	remove($_POST['id']);
}

$query = mysql_query("SELECT * FROM tb_funcionario WHERE id=".$_POST['id']);
$row = mysql_fetch_array($query);
$aniversario = explode('-', $row['aniversario']);

$query_user = mysql_query("SELECT * FROM tb_usuario WHERE id=".$_SESSION['id']);
$row_user = mysql_fetch_array($query_user);
$perfil = $row_user['perfil'];
include_once '../header.php';
?>
<body> 
<!-- Start: page-top-outer -->
<div id="page-top-outer">    
	<?php include_once '../menu.php';?>

<div id="page-heading"><h1>Editar Funcion&aacute;rio</h1></div>

<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="<?php echo EXTERNAL_ROOT_PORTAL;?>/css/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="<?php echo EXTERNAL_ROOT_PORTAL;?>/css/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
	<!--  start content-table-inner -->
	<div id="content-table-inner">
	<h3>Nome e sobrenome desativado para editar.</h3><br/>
<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
		<form method="post" action="edit.php">
			<tr>
				<th valign="top">Nome Completo *</th>
				<td><input type="text" class="inp-form" name="<?php if($perfil == 1){ echo 'nome"'; } ?>" <?php if($perfil != 1){ echo 'disabled="true"'; } ?> value="<?php echo $row['nome'];?>"/></td>
				<?php if($perfil != 1){ echo '<input type="hidden" name="nome" value="'.$row['nome'].'"/>'; } ?>
				<th valign="top">E-mail</th>
				<td><input type="text" class="inp-form" name="email" value="<?php echo $row['email'];?>"/></td>
			</tr>
			<tr>
				<th valign="top">CPF</th>
				<td><input type="text" class="inp-form" name="cpf" value="<?php echo $row['cpf'];?>"/></td>
				<th valign="top">RG</th>
				<td><input width="20px" type="text" class="inp-form" name="rg" value="<?php echo $row['rg'];?>"/></td>
			</tr>
			<tr>
				<th valign="top">Rua</th>
				<td><input type="text" class="inp-form" name="rua" value="<?php echo $row['rua'];?>"/></td>
				<th valign="top">N&uacute;mero</th>
				<td><input width="20px" type="text" class="inp-form" name="numero" value="<?php echo $row['numero'];?>"/></td>
			</tr>
			<tr>
				<th valign="top">Bairro</th>
				<td><input type="text" class="inp-form" name="bairro" value="<?php echo $row['bairro'];?>"/></td>
				<th valign="top">Complemento</th>
				<td><input type="text" class="inp-form" name="complemento" value="<?php echo $row['complemento'];?>"/></td>
			</tr>
			<tr>
				<th valign="top">Telefone</th>
				<td><input type="text" class="inp-form" name="tel" value="<?php echo $row['telefone'];?>"/></td>
				<th valign="top">Celular</th>
				<td><input type="text" class="inp-form" name="cel" value="<?php echo $row['celular'];?>"/></td>
			</tr>
			<tr>
				<th>Anivers&aacute;rio:</th>
				<td>
					<select name="dia">
						<option value="01" <?php if($aniversario[2]==01){echo 'selected="selected"' ;}?>>01</option>
						<option value="02" <?php if($aniversario[2]==02){echo 'selected="selected"' ;}?>>02</option>
						<option value="03" <?php if($aniversario[2]==03){echo 'selected="selected"' ;}?>>03</option>
						<option value="04" <?php if($aniversario[2]==04){echo 'selected="selected"' ;}?>>04</option>
						<option value="05" <?php if($aniversario[2]==05){echo 'selected="selected"' ;}?>>05</option>
						<option value="06" <?php if($aniversario[2]==06){echo 'selected="selected"' ;}?>>06</option>
						<option value="07" <?php if($aniversario[2]==07){echo 'selected="selected"' ;}?>>07</option>
						<option value="08" <?php if($aniversario[2]==08){echo 'selected="selected"' ;}?>>08</option>
						<option value="09" <?php if($aniversario[2]==09){echo 'selected="selected"' ;}?>>09</option>
						<?php 
							$count = 10;
							while($count < 32){
								if($aniversario[2]==$count){
									echo '<option value="'.$count.'" selected="selected">'.$count.'</option>';
								}else{
									echo '<option value="'.$count.'">'.$count.'</option>';
								}
								++$count;
							}
						?>
					</select>
					<select name="mes">
						<option value="01" <?php if($aniversario[1]==01){echo 'selected="selected"' ;} ?>>Janeiro</option>
						<option value="02" <?php if($aniversario[1]==02){echo 'selected="selected"' ;} ?>>Fevereiro</option>
						<option value="03" <?php if($aniversario[1]==03){echo 'selected="selected"' ;} ?>>Mar&ccedil;o</option>
						<option value="04" <?php if($aniversario[1]==04){echo 'selected="selected"' ;} ?>>Abril</option>
						<option value="05" <?php if($aniversario[1]==05){echo 'selected="selected"' ;} ?>>Maio</option>
						<option value="06" <?php if($aniversario[1]==06){echo 'selected="selected"' ;} ?>>Junho</option>
						<option value="07" <?php if($aniversario[1]==07){echo 'selected="selected"' ;} ?>>Julho</option>
						<option value="08" <?php if($aniversario[1]==08){echo 'selected="selected"' ;} ?>>Agosto</option>
						<option value="09" <?php if($aniversario[1]==09){echo 'selected="selected"' ;} ?>>Setembro</option>
						<option value="10" <?php if($aniversario[1]==10){echo 'selected="selected"' ;} ?>>Outubro</option>
						<option value="11" <?php if($aniversario[1]==11){echo 'selected="selected"' ;} ?>>Novembro</option>
						<option value="12" <?php if($aniversario[1]==12){echo 'selected="selected"' ;} ?>>Dezembro</option>
					</select>
				</td>
				<th>Perfil</th>
				<td>
					<select name="perfil">
						<option value="1" <?php if($row['perfil']==1){echo 'selected="selected"';}?>>Podologo</option>
						<option value="2" <?php if($row['perfil']==2){echo 'selected="selected"';}?>>Manicure</option>
						<option value="3" <?php if($row['perfil']==3){echo 'selected="selected"';}?>>Massagista</option>
						<option value="4" <?php if($row['perfil']==4){echo 'selected="selected"';}?>>Recepcionista</option>
					</select>
				</td>
			</tr>
			<input type="hidden" name="id" value="<?php echo $row['id'];?>">
			<input type="hidden" name="cmd" value="edit"/>
			<td valign="top">
				<td><input class="form-submit" type="submit" value=""></td>
			</td>
		</form>
 </table>
<div class="clear"></div>

</div>
<!--  end content-table-inner  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>

<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer -->

<div class="clear">&nbsp;</div>
    
<!-- start footer -->         
<div id="footer">
	<!--  start footer-left -->
	<div id="footer-left">
	Admin Skin &copy; Copyright Internet Dreams Ltd. <a href="">www.netdreams.co.uk</a>. All rights reserved.</div>
	<!--  end footer-left -->
	<div class="clear">&nbsp;</div>
</div>
<!-- end footer -->
 
</body>
</html>